<template>
  <div class='search'>
    <f-drawer ref='drawer' :title='title' width='880px' @submit='handleSubmit' @visibleChange='visibleChange'>
      <drugs-form ref='form' style='margin-bottom: 50px'></drugs-form>
    </f-drawer>
  </div>
</template>
<script>
import DrugsForm from "./drugs_form"

export default {
  name: "DrugsFormDrawer",
  props: {},
  data() {
    return {
      refs: this.$refs,
      drawerVisible: false,
      isEdit: false,
      formData: {}
    }
  },
  methods: {
    showDrawer(data) {
      this.isEdit = false
      if (data && data.policyDrugId) {
        this.isEdit = true
        this.formData = data
      } else {
        this.formData = {}
      }
      this.refs["drawer"].show()
      this.tabClick()
    },
    visibleChange(drawerVisible) {
      this.drawerVisible = drawerVisible
    },
    tabClick(compName) {
      this.$nextTick(() => {
        this.refs.form.setData(this.formData)
      })
    },
    handleSubmit(callback) {
      this.refs.form.handleSubmit(()=>{
        callback();
        this.$emit("success");
      })
    }
  },
  computed: {
    title: function() {
      return "修改全局结算政策"
    }
  },
  created() {
  },
  components: { DrugsForm }
}
</script>

<style scoped lang='less' rel='stylesheet/less'>

</style>
